package org.jinghouyu.json.utils;

import java.lang.reflect.Method;

public class ClassLoaderUtils {

	public static Class<?> defineClass(String name, byte[] bs) {
		ClassLoader loader = ClassLoaderUtils.class.getClassLoader();
		try {
			Method defineMethod = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] {String.class, byte[].class, int.class, int.class});
			defineMethod.setAccessible(true);
			return (Class<?>)defineMethod.invoke(loader, name, bs, 0, bs.length);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
